<?php


namespace App\Http\Controllers\admin\validate;


use Illuminate\Support\Facades\Validator;

class Banner
{
    public static function addBanner($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'banner_name'=>'required',
            'banner_img'=>'required'
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'banner_name.required'=>'banner图名称为空',
            'banner_img.required'=>'banner图地址为空'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryBanner($param){
        $rules = [
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];
        $msg = [
            'startSize.required'=>'当期页为空',
            'startSize.numeric'=>'当期页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryIdBanner($param){
        $rules = [
            'id'=>'required|numeric',
        ];
        $msg = [
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function editBanner($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'id'=>'required|numeric',
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对',
            'banner_name'=>'required',
            'banner_img'=>'required'
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'banner_name.required'=>'banner图名称为空',
            'banner_img.required'=>'banner图地址为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function deleteBanner($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'id'=>'required|numeric',
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对'
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }
}